home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / math / ast53src.zip / WDIALOG.C < prev    next >
C/C++ Source or Header  |  1996-09-29  |  57KB  |  1,822 lines

  1. /*
  2. ** Astrolog (Version 5.30) File: wdialog.c
  3. **
  4. ** IMPORTANT NOTICE: The graphics database and chart display routines
  5. ** used in this program are Copyright (C) 1991-1996 by Walter D. Pullen
  6. ** (Astara@msn.com, http://www.magitech.com/~cruiser1/astrolog.htm).
  7. ** Permission is granted to freely use and distribute these routines
  8. ** provided one doesn't sell, restrict, or profit from them in any way.
  9. ** Modification is allowed provided these notices remain with any
  10. ** altered or edited versions of the program.
  11. **
  12. ** The main planetary calculation routines used in this program have
  13. ** been Copyrighted and the core of this program is basically a
  14. ** conversion to C of the routines created by James Neely as listed in
  15. ** Michael Erlewine's 'Manual of Computer Programming for Astrologers',
  16. ** available from Matrix Software. The copyright gives us permission to
  17. ** use the routines for personal use but not to sell them or profit from
  18. ** them in any way.
  19. **
  20. ** The PostScript code within the core graphics routines are programmed
  21. ** and Copyright (C) 1992-1993 by Brian D. Willoughby
  22. ** (brianw@sounds.wa.com). Conditions are identical to those above.
  23. **
  24. ** The extended accurate ephemeris databases and formulas are from the
  25. ** calculation routines in the program "Placalc" and are programmed and
  26. ** Copyright (C) 1989,1991,1993 by Astrodienst AG and Alois Treindl
  27. ** (alois@azur.ch). The use of that source code is subject to
  28. ** regulations made by Astrodienst Zurich, and the code is not in the
  29. ** public domain. This copyright notice must not be changed or removed
  30. ** by any user of this program.
  31. **
  32. ** Initial programming 8/28,30, 9/10,13,16,20,23, 10/3,6,7, 11/7,10,21/1991.
  33. ** X Window graphics initially programmed 10/23-29/1991.
  34. ** PostScript graphics initially programmed 11/29-30/1992.
  35. ** Last code change made 9/22/1996.
  36. */
  37.  
  38. #include "astrolog.h"
  39.  
  40.  
  41. #ifdef WIN
  42. /*
  43. ******************************************************************************
  44. ** Dialog Utility Functions.
  45. ******************************************************************************
  46. */
  47.  
  48. /* Set the contents of the given edit control in a dialog to a string. */
  49.  
  50. void SetEditSz(hdlg, id, sz)
  51. HWND hdlg;
  52. int id;
  53. char *sz;
  54. {
  55.   while (*sz == ' ')    /* Strip off any extra leading spaces. */
  56.     sz++;
  57.   SetEdit(id, sz);
  58. }
  59.  
  60.  
  61. /* Set the contents of the given edit control in a dialog to a floating */
  62. /* point value, with at most 'n' significant fractional digits.         */
  63.  
  64. void SetEditR(hdlg, id, r, n)
  65. HWND hdlg;
  66. int id;
  67. real r;
  68. int n;
  69. {
  70.   char sz[cchSzDef], szT[8], *pch;
  71.  
  72.   sprintf(szT, "%%.%df", n);
  73.   sprintf(sz, szT, r);
  74.   for (pch = sz; *pch; pch++)
  75.     ;
  76.   while (*(--pch) == '0')          /* Drop off any trailing zero digits. */
  77.     ;
  78.   pch[1 + (*pch == '.')] = chNull; /* Ensure at least one fractional digit. */
  79.   SetEdit(id, sz);
  80. }
  81.  
  82.  
  83. /* Set the contents of four combo controls and their dropdowns in a dialog */
  84. /* indicating month, day, year, and time fields to the given values.       */
  85.  
  86. void SetEditMDYT(hdlg, idMon, idDay, idYea, idTim, mon, day, yea, tim)
  87. HWND hdlg;
  88. int idMon, idDay, idYea, idTim;
  89. int mon, day, yea;
  90. real tim;
  91. {
  92.   char sz[cchSzDef];
  93.   int i;
  94.  
  95.   ClearCombo(idMon);
  96.   ClearCombo(idDay);
  97.   ClearCombo(idYea);
  98.   ClearCombo(idTim);
  99.   if (!FValidMon(mon))
  100.     mon = 1;
  101.   sprintf(sz, "%c%c%c", chMon3(mon));
  102.   SetEdit(idMon, sz);
  103.   for (i = 1; i <= cSign; i++)
  104.     SetCombo(idMon, szMonth[i]);
  105.   if (!FValidDay(day, mon, yea))
  106.     day = 1;
  107.   SetEditN(idDay, day);
  108.   SetCombo(idDay, "1"); SetCombo(idDay, "15");
  109.   SetEditN(idYea, yea);
  110.   for (i = 1990; i < 2000; i++) {
  111.     sprintf(sz, "%d", i); SetCombo(idYea, sz);
  112.   }
  113.   sprintf(sz, "%s", SzTim(tim));
  114.   SetEditSz(hdlg, idTim, sz);
  115.   SetCombo(idTim, "Midnight");
  116.   SetCombo(idTim, (char *)(us.fEuroTime ? "6:00" : "6:00am"));
  117.   SetCombo(idTim, "Noon");
  118.   SetCombo(idTim, (char *)(us.fEuroTime ? "18:00" : "6:00pm"));
  119. }
  120.  
  121.  
  122. /* Set the contents of four combo controls in a dialog indicating daylight, */
  123. /* time zone, longitude, and latitude fields to the given values.           */
  124.  
  125. void SetEditSZOA(hdlg, idDst, idZon, idLon, idLat, dst, zon, lon, lat)
  126. HWND hdlg;
  127. int idDst, idZon, idLon, idLat;
  128. real dst, zon, lon, lat;
  129. {
  130.   char sz[cchSzDef];
  131.   int i;
  132.   bool fT;
  133.  
  134.   if (dst == 0.0 || dst == 1.0)
  135.     sprintf(sz, "%s", dst == 0.0 ? "No" : "Yes");
  136.   else
  137.     sprintf(sz, "%.2f", dst);
  138.   SetEdit(idDst, sz);
  139.   SetCombo(idDst, "No"); SetCombo(idDst, "Yes");
  140.   sprintf(sz, "%s", SzZone(-zon));
  141.   SetEdit(idZon, (char *)(sz[0] == '+' ? &sz[1] : sz));
  142.   /* For the time zone dropdown, fill it out with all abbreviations of */
  143.   /* three letters that don't reference daylight or war time.          */
  144.   for (i = 0; i < cZone; i++) {
  145.     if (szZon[i][1] && szZon[i][1] != 'D' && szZon[i][1] != 'W' &&
  146.       szZon[i][2] && szZon[i][2] != 'D')
  147.       SetCombo(idZon, szZon[i]);
  148.   }
  149.   fT = us.fAnsiChar; us.fAnsiChar = fFalse;
  150.   sprintf(sz, "%s", SzLocation(lon, lat));
  151.   us.fAnsiChar = fT;
  152.   sz[7] = chNull;
  153.   SetEditSz(hdlg, idLon, &sz[0]);
  154.   SetCombo(idLon, "122W20"); SetCombo(idLon, "0E00");
  155.   SetEditSz(hdlg, idLat, &sz[8]);
  156.   SetCombo(idLat, "47N36"); SetCombo(idLat, "0S00");
  157. }
  158.  
  159.  
  160. /* Set the contents of a combo control in a dialog indicating a color   */
  161. /* field to the given value, and fill its dropdown with the color list. */
  162.  
  163. void SetEditColor(hdlg, id, ki)
  164. HWND hdlg;
  165. int id;
  166. KI ki;
  167. {
  168.   int i;
  169.  
  170.   SetEdit(id, szColor[ki]);
  171.   for (i = 0; i < cColor; i++)
  172.     SetCombo(id, szColor[i]);
  173. }
  174.  
  175.  
  176. /* Return the contents of a dialog edit control as a floating point value. */
  177.  
  178. real GetEditR(hdlg, id)
  179. HWND hdlg;
  180. int id;
  181. {
  182.   char sz[cchSzDef];
  183.  
  184.   GetEdit(id, sz);
  185.   return atof(sz);
  186. }
  187.  
  188.  
  189. /* Bring up an error box indicating an illegal value for a dialog field. */
  190.  
  191. void ErrorEnsure(n, sz)
  192. int n;
  193. char *sz;
  194. {
  195.   char szT[cchSzDef];
  196.  
  197.   sprintf(szT, "The value %d is not a valid %s setting.", n, sz);
  198.   PrintWarning(szT);
  199. }
  200.  
  201.  
  202. /* Take many of the user visible settings, and write them out to a new     */
  203. /* command switch file, which may be read in to restore those settings.    */
  204. /* Most often this would be used to create a new astrolog.dat default      */
  205. /* settings file. This is called from the File Save Settings menu command. */
  206.  
  207. bool FOutputSettings()
  208. {
  209.   char sz[cchSzDef];
  210.   FILE *file;
  211.   int i;
  212.   bool fT;
  213.  
  214.   if (us.fNoWrite)
  215.     return fFalse;
  216.   file = fopen(is.szFileOut, "w");  /* Create and open the file for output. */
  217.   if (file == NULL) {
  218.     sprintf(sz, "Settings file %s can not be created.", is.szFileOut);
  219.     PrintError(sz);
  220.     return fFalse;
  221.   }
  222.  
  223.   sprintf(sz, "@0308  ; %s (%s) default settings file %s\n\n",
  224.     szAppName, szVersionCore, DEFAULT_INFOFILE); PrintFSz();
  225.  
  226.   sprintf(sz, "-z0 %d             ", (int)us.dstDef); PrintFSz();
  227.   PrintF("; Default Daylight time setting   [0 standard, 1 daylight]\n");
  228.   sprintf(sz, "-z %s          ", SzZone(-us.zonDef)); PrintFSz();
  229.   PrintF("; Default time zone               [hours before GMT      ]\n");
  230.   fT = us.fAnsiChar; us.fAnsiChar = 3;
  231.   sprintf(sz, "-zl %s  ", SzLocation(us.lonDef, us.latDef)); PrintFSz();
  232.   us.fAnsiChar = fT;
  233.   PrintF("; Default longitude and latitude\n\n");
  234.  
  235.   sprintf(sz, "%cs      ", ChDashF(us.fSidereal)); PrintFSz();
  236.   PrintF(
  237.     "; Zodiac selection          [\"_s\" is tropical, \"=s\" is siderial]\n");
  238.   sprintf(sz, ":s %.0f    ", us.rZodiacOffset); PrintFSz();
  239.   PrintF(
  240.     "; Zodiac offset value       [Change \"0\" to desired offset      ]\n");
  241.   sprintf(sz, "-A %d    ", us.nAsp); PrintFSz();
  242.   PrintF(
  243.     "; Number of aspects         [Change \"5\" to desired number      ]\n");
  244.   sprintf(sz, "-c %d    ", us.nHouseSystem); PrintFSz();
  245.   PrintF(
  246.     "; House system              [Change \"0\" to desired system      ]\n");
  247.   sprintf(sz, "%ck      ", ChDashF(us.fAnsiColor)); PrintFSz();
  248.   PrintF(
  249.     "; Ansi color text           [\"=k\" is color, \"_k\" is normal     ]\n");
  250.   sprintf(sz, ":d %d   ", us.nDivision); PrintFSz();
  251.   PrintF(
  252.     "; Searching divisions       [Change \"12\" to desired divisions  ]\n");
  253.   sprintf(sz, "%cb0     ", ChDashF(us.fSeconds)); PrintFSz();
  254.   PrintF(
  255.     "; Print zodiac seconds      [\"_b0\" to minute, \"=b0\" to second  ]\n");
  256.   sprintf(sz, "%cb      ", ChDashF(us.fPlacalc)); PrintFSz();
  257.   PrintF(
  258.     "; Use ephemeris files       [\"=b\" uses them, \"_b\" doesn't      ]\n");
  259.   sprintf(sz, "%cC      ", ChDashF(us.fCusp)); PrintFSz();
  260.   PrintF(
  261.     "; Show house cusp objects   [\"_C\" hides them, \"=C\" shows them  ]\n");
  262.   sprintf(sz, ":w %d    ", us.nWheelRows); PrintFSz();
  263.   PrintF(
  264.     "; Wheel chart text rows     [Change \"4\" to desired wheel rows  ]\n");
  265.   sprintf(sz, ":I %d   ", us.nScreenWidth); PrintFSz();
  266.   PrintF(
  267.     "; Text screen columns       [Change \"80\" to desired columns    ]\n");
  268.   sprintf(sz, "-YQ %d  ", us.nScrollRow); PrintFSz();
  269.   PrintF(
  270.     "; Text screen scroll limit  [Change \"24\" or set to \"0\" for none]\n");
  271.   sprintf(sz, "%cYd     ", ChDashF(us.fEuroDate)); PrintFSz();
  272.   PrintF(
  273.     "; European date format      [\"_Yd\" is MDY, \"=Yd\" is DMY        ]\n");
  274.   sprintf(sz, "%cYt     ", ChDashF(us.fEuroTime)); PrintFSz();
  275.   PrintF(
  276.     "; European time format      [\"_Yt\" is AM/PM, \"=Yt\" is 24 hour  ]\n");
  277.   sprintf(sz, "%cYC     ", ChDashF(us.fSmartCusp)); PrintFSz();
  278.   PrintF(
  279.     "; Smart cusp displays       [\"=YC\" is smart, \"_YC\" is normal   ]\n");
  280.   sprintf(sz, "%cY8     ", ChDashF(us.fClip80)); PrintFSz();
  281.   PrintF(
  282.     "; Clip text to end of line  [\"=Y8\" clips, \"_Y8\" doesn't clip   ]\n");
  283.   sprintf(sz, "-Yz %ld   ", us.lTimeAddition); PrintFSz();
  284.   PrintF(
  285.     "; Time minute addition      [Change only if -n charts are off  ]\n\n-n");
  286.   PrintF(
  287.     "      ; Uncomment this line to start with the chart for \"now\".\n\n\n");
  288.  
  289.   PrintF("; DEFAULT RESTRICTIONS:\n\n-YR 1 10     ");
  290.   for (i = 1; i <= 10; i++) PrintF(SzNumF(ignore[i]));
  291.   PrintF("     ; Planets\n-YR 11 20    ");
  292.   for (i = 11; i <= 20; i++) PrintF(SzNumF(ignore[i]));
  293.   PrintF("     ; Minor planets\n-YR 21 32    ");
  294.   for (i = 21; i <= 32; i++) PrintF(SzNumF(ignore[i]));
  295.   PrintF(" ; House cusps\n-YR 33 40    ");
  296.   for (i = 33; i <= 40; i++) PrintF(SzNumF(ignore[i]));
  297.   PrintF("         ; Uranians\n\n");
  298.  
  299.   PrintF("; DEFAULT TRANSIT RESTRICTIONS:\n\n-YRT 1 10    ");
  300.   for (i = 1; i <= 10; i++) PrintF(SzNumF(ignore2[i]));
  301.   PrintF("     ; Planets\n-YRT 11 20   ");
  302.   for (i = 11; i <= 20; i++) PrintF(SzNumF(ignore2[i]));
  303.   PrintF("     ; Minor planets\n-YRT 21 32   ");
  304.   for (i = 21; i <= 32; i++) PrintF(SzNumF(ignore2[i]));
  305.   PrintF(" ; House cusps\n-YRT 33 40   ");
  306.   for (i = 33; i <= 40; i++) PrintF(SzNumF(ignore2[i]));
  307.   PrintF("         ; Uranians\n\n");
  308.  
  309.   sprintf(sz, "-YR0 %s%s ; Restrict sign, direction changes\n\n\n",
  310.     SzNumF(us.fIgnoreSign), SzNumF(us.fIgnoreDir)); PrintFSz();
  311.  
  312.   PrintF("; DEFAULT ASPECT ORBS:\n\n-YAo 1 5    ");
  313.   for (i = 1; i <= 5; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
  314.   PrintF("      ; Major aspects\n-YAo 6 11   ");
  315.   for (i = 6; i <= 11; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
  316.   PrintF("    ; Minor aspects\n-YAo 12 18  ");
  317.   for (i = 12; i <= 18; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
  318.   PrintF("  ; Obscure aspects\n\n");
  319.  
  320.   PrintF("; DEFAULT MAX PLANET ASPECT ORBS:\n\n-YAm 1 10   ");
  321.   for (i = 1; i <= 10; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
  322.   PrintF("\n-YAm 11 20  ");
  323.   for (i = 11; i <= 20; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
  324.   PrintF("\n-YAm 21 32  ");
  325.   for (i = 21; i <= 32; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
  326.   PrintF("\n-YAm 33 40  ");
  327.   for (i = 33; i <= 40; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
  328.  
  329.   PrintF("\n\n; DEFAULT PLANET ASPECT ORB ADDITIONS:\n\n-YAd 1 10   ");
  330.   for (i = 1; i <= 10; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
  331.   PrintF("\n-YAd 11 20  ");
  332.   for (i = 11; i <= 20; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
  333.   PrintF("\n-YAd 21 32  ");
  334.   for (i = 21; i <= 32; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
  335.  
  336.   PrintF("\n\n\n; DEFAULT INFLUENCES:\n\n-Yj 1 10   ");
  337.   for (i = 1; i <= 10; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
  338.   PrintF("        ; Planets\n-Yj 11 20  ");
  339.   for (i = 11; i <= 20; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
  340.   PrintF("                  ; Minor planets\n-Yj 21 32  ");
  341.   for (i = 21; i <= 32; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
  342.   PrintF("  ; Cusp objects\n-Yj 33 40  ");
  343.   for (i = 33; i <= 40; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
  344.   PrintF("                      ; Uranians\n\n-YjC 1 12  ");
  345.  
  346.   for (i = 1; i <= 12; i++) { sprintf(sz, " %.0f", rHouseInf[i]); PrintFSz(); }
  347.   PrintF("  ; Houses\n\n-YjA 1 5   ");
  348.  
  349.   for (i = 1; i <= 5; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
  350.   PrintF("          ; Major aspects\n-YjA 6 11  ");
  351.   for (i = 6; i <= 11; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
  352.   PrintF("      ; Minor aspects\n-YjA 12 18 ");
  353.   for (i = 12; i <= 18; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
  354.   PrintF("  ; Obscure aspects\n\n");
  355.  
  356.   PrintF("; DEFAULT TRANSIT INFLUENCES:\n\n-YjT 1 10   ");
  357.   for (i = 1; i <= 10; i++)
  358.     { sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
  359.   PrintF("  ; Planets\n-YjT 11 20  ");
  360.   for (i = 11; i <= 20; i++)
  361.     { sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
  362.   PrintF("   ; Minor planets\n-YjT 33 40  ");
  363.   for (i = 33; i <= 40; i++)
  364.     { sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
  365.  
  366.   sprintf(sz, "     ; Uranians\n\n-Yj0 %.0f %.0f %.0f %.0f ",
  367.     rObjInf[oNorm + 1], rObjInf[oNorm + 2], rHouseInf[cSign + 1],
  368.     rHouseInf[cSign + 2]); PrintFSz();
  369.   PrintF("; In ruling sign, exalted sign, ruling house, exalted house.\n\n\n");
  370.  
  371.   PrintF("; DEFAULT COLORS:\n\n-YkC");
  372.   for (i = eFir; i <= eWat; i++) { sprintf(sz, " %d", kElemA[i]); PrintFSz(); }
  373.   PrintF("                 ; Element colors\n-YkA 1 18 ");
  374.   for (i = 1; i <= cAspect; i++) { sprintf(sz, " %d", kAspA[i]); PrintFSz(); }
  375.   PrintF("  ; Aspect colors\n-Yk0 1 7  ");
  376.   for (i = 1; i <= 7; i++) { sprintf(sz, " %d", kRainbowA[i]); PrintFSz(); }
  377.   PrintF("    ; Rainbow colors\n-Yk  0 8  ");
  378.   for (i = 0; i <= 8; i++) { sprintf(sz, " %d", kMainA[i]); PrintFSz(); }
  379.   PrintF("  ; Main colors\n\n\n");
  380.  
  381.   PrintF("; GRAPHICS DEFAULTS:\n\n");
  382.   sprintf(sz, "%cX              ", ChDashF(us.fGraphics)); PrintFSz();
  383.   PrintF("; Graphics chart flag [\"_X\" is text, \"=X\" is graphics]\n");
  384.   i = gs.xWin; if (fSidebar) i -= SIDESIZE;
  385.   sprintf(sz, ":Xw %d %d     ", i, gs.yWin); PrintFSz();
  386.   PrintF("; Default X and Y resolution\n");
  387.   sprintf(sz, ":Xb%c            ", ChUncap(gs.chBmpMode)); PrintFSz();
  388.   PrintF("; Bitmap file type\n");
  389.   sprintf(sz, ":YXG %d       ", gs.nGlyphs); PrintFSz();
  390.   PrintF("; Glyph selections\n");
  391.   sprintf(sz, ":YXg %d         ", gs.nGridCell); PrintFSz();
  392.   PrintF("; Aspect grid cells\n");
  393.   sprintf(sz, ":YXf %d          ", gs.fFont); PrintFSz();
  394.   PrintF("; Use actual fonts\n");
  395.   sprintf(sz, ":YXp %d          ", gs.nOrient); PrintFSz();
  396.   PrintF("; PostScript paper orientation\n");
  397.   sprintf(sz, ":YXp0 %.1f %.1f  ", gs.xInch, gs.yInch); PrintFSz();
  398.   PrintF("; PostScript paper X and Y inch sizes\n");
  399.   PrintF(":YX -1 16       ; PC hi-res and lo-res graphics modes\n\n");
  400.  
  401.   sprintf(sz, "; %s\n", DEFAULT_INFOFILE); PrintFSz();
  402.   fclose(file);
  403.   return fTrue;
  404. }
  405.  
  406.  
  407. /*
  408. ******************************************************************************
  409. ** Windows Dialogs.
  410. ******************************************************************************
  411. */
  412.  
  413. /* Bring up the Windows standard file open dialog, and process the        */
  414. /* command file specified if any. This is called from the File Open Chart */
  415. /* and File Open Chart #2 menu commands.                                  */
  416.  
  417. bool API DlgOpenChart()
  418. {
  419.   char sz[cchSzDef];
  420.   CI ciT;
  421.  
  422.   /* Setup dialog title and settings and get the name of a file from it. */
  423.   if (us.fNoRead) {
  424.     PrintWarning("File input is not allowed now.");
  425.     return fFalse;
  426.   }
  427.   sprintf(sz, "Open Chart #%d", wi.nDlgChart);
  428.   if (wi.nDlgChart < 2)
  429.     sz[10] = chNull;
  430.   ofn.lpstrTitle = sz;
  431.   ofn.lpstrFilter = "All Files (*.*)\0*.*\0Data Files (*.DAT)\0*.DAT\0";
  432.   szFileName[0] = chNull;
  433.   if (!GetOpenFileName((LPOPENFILENAME)&ofn))
  434.     return fFalse;
  435.  
  436.   /* Process the given file based on what open command is being run. */
  437.   ciT = ciCore;
  438.   FInputData(ofn.lpstrFileTitle);
  439.   if (wi.nDlgChart > 1) {
  440.     if (wi.nDlgChart == 2)
  441.       ciTwin = ciCore;
  442.     else if (wi.nDlgChart == 3)
  443.       ciThre = ciCore;
  444.     else
  445.       ciFour = ciCore;
  446.     ciCore = ciT;
  447.   }
  448.  
  449.   wi.fCast = fTrue;
  450.   return fTrue;
  451. }
  452.  
  453.  
  454. /* Bring up the Windows standard file save dialog, get the name of a file   */
  455. /* from the user, and save to it either right away or set variables to      */
  456. /* ensure it will be done later. This is called from all six File Save menu */
  457. /* commands: Save Info, Positions, Text, Bitmap, Picture, and PostScript.   */
  458.  
  459. bool API DlgSaveChart()
  460. {
  461.   char *pch;
  462.  
  463.   /* Setup dialog title and settings and get the name of a file from it. */
  464.   if (us.fNoWrite) {
  465.     PrintWarning("File output is not allowed now.");
  466.     return fFalse;
  467.   }
  468.   ofn.lpstrFilter = "All Files (*.*)\0*.*\0Data Files (*.DAT)\0*.DAT\0";
  469.   szFileName[0] = chNull;
  470.   switch (wi.wCmd) {
  471.   case cmdSaveChart:
  472.     ofn.lpstrTitle = "Save Chart Info";
  473.     break;
  474.   case cmdSavePositions:
  475.     ofn.lpstrTitle = "Save Chart Positions";
  476.     break;
  477.   case cmdSaveText:
  478.     ofn.lpstrTitle = "Save Chart Text";
  479.     ofn.lpstrFilter = "All Files (*.*)\0*.*\0Text Files (*.TXT)\0*.TXT\0";
  480.     break;
  481.   case cmdSaveBitmap:
  482.     ofn.lpstrTitle = "Save Chart Bitmap";
  483.     ofn.lpstrFilter =
  484.       "Windows Bitmap (*.BMP)\0*.BMP\0All Files (*.*)\0*.*\0";
  485.     break;
  486.   case cmdSavePicture:
  487.     ofn.lpstrTitle = "Save Chart Picture";
  488.     ofn.lpstrFilter =
  489.       "Windows Metafile (*.WMF)\0*.WMF\0All Files (*.*)\0*.*\0";
  490.     break;
  491.   case cmdSavePS:
  492.     ofn.lpstrTitle = "Save Chart PostScript";
  493.     ofn.lpstrFilter =
  494.       "PostScript Text (*.EPS)\0*.EPS\0All Files (*.*)\0*.*\0";
  495.     break;
  496.   case cmdSaveSettings:
  497.     ofn.lpstrTitle = "Save Settings";
  498.     ofn.lpstrFilter = "Data Files (*.DAT)\0*.DAT\0All Files (*.*)\0*.*\0";
  499.     sprintf(szFileName, "%s", DEFAULT_INFOFILE);
  500.     break;
  501.   }
  502.   if (wi.wCmd != cmdSaveWallTile && wi.wCmd != cmdSaveWallCenter) {
  503.     if (!GetSaveFileName((LPOPENFILENAME)&ofn))
  504.       return fFalse;
  505.   } else {
  506.     ofn.lpstrFile = PAllocate(cchSzDef, fTrue, NULL);
  507.     GetWindowsDirectory(ofn.lpstrFile, cchSzDef);
  508.     pch = ofn.lpstrFile + CchSz(ofn.lpstrFile);
  509.     sprintf(pch, "%c%s%s", '\\', szAppName, ".bmp");
  510.   }
  511.  
  512.   /* Saving chart info, position, or setting command files can be done  */
  513.   /* here. Saving actual chart output isn't done until the next redraw. */
  514.   is.szFileOut = gi.szFileOut = ofn.lpstrFile;
  515.   switch (wi.wCmd) {
  516.   case cmdSaveChart:
  517.     us.fWritePos = fFalse;
  518.     return FOutputData();
  519.   case cmdSavePositions:
  520.     us.fWritePos = fTrue;
  521.     return FOutputData();
  522.   case cmdSaveText:
  523.     is.szFileScreen = ofn.lpstrFile;
  524.     us.fGraphics = fFalse;
  525.     wi.fRedraw = fTrue;
  526.     break;
  527.   case cmdSaveBitmap:
  528.   case cmdSaveWallTile:
  529.   case cmdSaveWallCenter:
  530.     gs.fBitmap = fTrue;
  531.     gs.fMeta = gs.fPS = fFalse;
  532.     us.fGraphics = wi.fRedraw = fTrue;
  533.     break;
  534.   case cmdSavePicture:
  535.     gs.fMeta = fTrue;
  536.     gs.fBitmap = gs.fPS = fFalse;
  537.     us.fGraphics = wi.fRedraw = fTrue;
  538.     break;
  539.   case cmdSavePS:
  540.     gs.fPS = fTrue;
  541.     gs.fBitmap = gs.fMeta = fFalse;
  542.     us.fGraphics = wi.fRedraw = fTrue;
  543.     break;
  544.   case cmdSaveSettings:
  545.     return FOutputSettings();
  546.   }
  547.   return fTrue;
  548. }
  549.  
  550.  
  551. /* Bring up the Windows standard print dialog, receive any printing       */
  552. /* settings from the user, and proceed to print the current graphics or   */
  553. /* text chart as displayed in the window. Called from File Print command. */
  554.  
  555. bool API DlgPrint()
  556. {
  557.   FARPROC lpAbortDlg, lpAbortProc;
  558.   HDC hdc;
  559.   LPDEVMODE lpDevMode = NULL;
  560.   LPDEVNAMES lpDevNames;
  561.   LPSTR lpszDriverName;
  562.   LPSTR lpszDeviceName;
  563.   LPSTR lpszPortName;
  564.   DOCINFO doci;
  565.   int xPrint, yPrint;
  566.   int xClient, yClient;
  567.  
  568.   /* Bring up the Windows print dialog. */
  569.   wi.fNoUpdate = fFalse;
  570.   if (!PrintDlg((LPPRINTDLG)&prd))
  571.     return fTrue;
  572.  
  573.   /* Get the printer DC. */
  574.   if (prd.hDC)
  575.     hdc = prd.hDC;
  576.   else {
  577.     /* If the dialog didn't just return the DC, try to make one manually. */
  578.     if (!prd.hDevNames)
  579.       return fFalse;
  580.     lpDevNames = (LPDEVNAMES)GlobalLock(prd.hDevNames);
  581.     lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
  582.     lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
  583.     lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
  584.     GlobalUnlock(prd.hDevNames);
  585.     if (prd.hDevMode)
  586.       lpDevMode = (LPDEVMODE)GlobalLock(prd.hDevMode);
  587.     hdc = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName,
  588.       (LPSTR)lpDevMode);
  589.     if (prd.hDevMode && lpDevMode)
  590.       GlobalUnlock(prd.hDevMode);
  591.   }
  592.   if (prd.hDevNames) {
  593.     GlobalFree(prd.hDevNames);
  594.     prd.hDevNames = (HGLOBAL)NULL;
  595.   }
  596.   if (prd.hDevMode) {
  597.     GlobalFree(prd.hDevMode);
  598.     prd.hDevMode = (HGLOBAL)NULL;
  599.   }
  600.  
  601.   /* Setup the abort dialog and start the print job. */
  602.   lpAbortDlg = MakeProcInstance(DlgAbort, wi.hinst);
  603.   lpAbortProc = MakeProcInstance(DlgAbortProc, wi.hinst);
  604.   SetAbortProc(hdc, lpAbortProc);
  605.   doci.cbSize = sizeof(DOCINFO);
  606.   doci.lpszDocName = szAppName;
  607.   doci.lpszOutput = NULL;
  608.   if (StartDoc(hdc, &doci) < 0) {
  609.     FreeProcInstance(lpAbortDlg);
  610.     FreeProcInstance(lpAbortProc);
  611.     DeleteDC(hdc);
  612.     return fFalse;
  613.   }
  614.   wi.fAbort = FALSE;
  615.   wi.hwndAbort = CreateDialog(wi.hinst, MAKEINTRESOURCE(dlgAbort), wi.hwnd,
  616.     lpAbortDlg);
  617.   if (!wi.hwndAbort)
  618.     return fFalse;
  619.   ShowWindow(wi.hwndAbort, SW_NORMAL);
  620.   EnableWindow(wi.hwnd, fFalse);
  621.   StartPage(hdc);
  622.  
  623.   /* Scale the chart to the page. */
  624.   if (us.fGraphics) {
  625.     gs.xWin *= METAMUL; gs.yWin *= METAMUL; gs.nScale *= METAMUL;
  626.   }
  627.   SetMapMode(hdc, MM_ANISOTROPIC);       /* So SetViewPortExt can be called */
  628.   xPrint = GetDeviceCaps(hdc, HORZRES);
  629.   yPrint = GetDeviceCaps(hdc, VERTRES);
  630.   SetViewportOrg(hdc, 0, 0);
  631.   SetViewportExt(hdc, xPrint, yPrint);
  632.   xClient = wi.xClient; yClient = wi.yClient;
  633.   wi.xClient = gs.xWin;
  634.   wi.yClient = NMultDiv(wi.xClient, yPrint, xPrint);
  635.   if (gs.yWin > wi.yClient) {
  636.     wi.yClient = gs.yWin;
  637.     wi.xClient = NMultDiv(wi.yClient, xPrint, yPrint);
  638.   }
  639.   wi.hdcPrint = hdc;
  640.  
  641.   FRedraw();    /* Actually go "draw" the chart to the printer. */
  642.  
  643.   /* Restore globals that were temporarily changed to print above. */
  644.   wi.hdcPrint = hdcNil;
  645.   wi.xClient = xClient; wi.yClient = yClient;
  646.   if (us.fGraphics) {
  647.     gs.xWin /= METAMUL; gs.yWin /= METAMUL; gs.nScale /= METAMUL;
  648.   }
  649.  
  650.   /* Finalize and cleanup everything. */
  651.   if (!wi.fAbort) {
  652.     EndPage(hdc);
  653.     EndDoc(hdc);
  654.   }
  655.   EnableWindow(wi.hwnd, fTrue);
  656.   DestroyWindow(wi.hwndAbort);
  657.   FreeProcInstance(DlgAbort);
  658.   FreeProcInstance(DlgAbortProc);
  659.   DeleteDC(hdc);
  660.  
  661.   return fTrue;
  662. }
  663.  
  664.  
  665. /* Message loop function for the printing abort dialog. Loops until       */
  666. /* printing is completed or the user hits cancel, returning which result. */
  667.  
  668. bool API EXPORT DlgAbortProc(hdc, nCode)
  669. HDC hdc;
  670. int nCode;
  671. {
  672.   MSG msg;
  673.  
  674.   if (wi.hwndAbort == (HWND)NULL)
  675.     return fTrue;
  676.   while (!wi.fAbort && PeekMessage(&msg, (HWND)NULL, 0, 0, PM_REMOVE))
  677.     if (!IsDialogMessage(wi.hwndAbort, &msg)) {
  678.       TranslateMessage(&msg);
  679.       DispatchMessage(&msg);
  680.     }
  681.   return !wi.fAbort;
  682. }
  683.  
  684.  
  685. /* Processing function for the printing abort modeless dialog, as brought */
  686. /* up temporarily when printing via the File Print menu command.          */
  687.  
  688. bool API DlgAbort(hdlg, message, wParam, lParam)
  689. HWND hdlg;
  690. _int message;
  691. WORD wParam;
  692. LONG lParam;
  693. {
  694.   switch (message) {
  695.   case WM_INITDIALOG:
  696.     SetFocus(GetDlgItem(hdlg, IDCANCEL));
  697.     return fFalse;
  698.  
  699.   case WM_COMMAND:
  700.     if (wParam == IDOK || wParam == IDCANCEL) {
  701.       wi.fAbort = fTrue;
  702.       EndDialog(hdlg, fTrue);
  703.       return fTrue;
  704.     }
  705.     break;
  706.   }
  707.   return fFalse;
  708. }
  709.  
  710.  
  711. /* Processing function for the command switch entry dialog, as brought up */
  712. /* with the Edit Enter Command Line menu command.                         */
  713.  
  714. bool API DlgCommand(hdlg, message, wParam, lParam)
  715. HWND hdlg;
  716. _int message;
  717. WORD wParam;
  718. LONG lParam;
  719. {
  720.   char sz[cchSzDef];
  721.  
  722.   switch (message) {
  723.   case WM_INITDIALOG:
  724.     SetFocus(GetDlgItem(hdlg, deCo));
  725.     return fFalse;
  726.  
  727.   case WM_COMMAND:
  728.     if (wParam == IDOK) {
  729.       GetDlgItemText(hdlg, deCo, sz, cchSzDef);
  730.       FProcessCommandLine(sz);
  731.       wi.fCast = wi.fMenuAll = fTrue;
  732.     }
  733.     if (wParam == IDOK || wParam == IDCANCEL) {
  734.       EndDialog(hdlg, fTrue);
  735.       return fTrue;
  736.     }
  737.     break;
  738.   }
  739.   return fFalse;
  740. }
  741.  
  742.  
  743. /* Processing function for the color customization dialog, as brought up */
  744. /* with the View Set Colors menu command.                                */
  745.  
  746. bool API DlgColor(hdlg, message, wParam, lParam)
  747. HWND hdlg;
  748. _int message;
  749. WORD wParam;
  750. LONG lParam;
  751. {
  752.   char sz[cchSzDef];
  753.   int i, j, k, l;
  754.  
  755.   switch (message) {
  756.   case WM_INITDIALOG:
  757.     for (i = 0; i < 4; i++)
  758.       SetEditColor(hdlg, dce0 + i, kElemA[i]);
  759.     for (i = 1; i <= cAspect; i++)
  760.       SetEditColor(hdlg, dca01 + i - 1, kAspA[i]);
  761.     for (i = 0; i < cColor; i++) {
  762.       j = ikPalette[i];
  763.       SetEditColor(hdlg, dck00 + i, j <= 0 ? kMainA[-j] : kRainbowA[j]);
  764.     }
  765.     return fTrue;
  766.  
  767.   case WM_COMMAND:
  768.     if (wParam == IDOK) {
  769.       for (k = 0; k <= 1; k++) {
  770.         for (i = 0; i < 4; i++) {
  771.           GetEdit(dce0 + i, sz);
  772.           l = NParseSz(sz, pmColor);
  773.           if (k)
  774.             kElemA[i] = l;
  775.           else
  776.             EnsureN(l, FValidColor(l), "element color");
  777.         }
  778.         for (i = 1; i <= cAspect; i++) {
  779.           GetEdit(dca01 + i - 1, sz);
  780.           l = NParseSz(sz, pmColor);
  781.           if (k)
  782.             kAspA[i] = l;
  783.           else
  784.             EnsureN(l, FValidColor(l), "aspect color");
  785.         }
  786.         for (i = 0; i < cColor; i++) {
  787.           GetEdit(dck00 + i, sz);
  788.           l = NParseSz(sz, pmColor);
  789.           if (k) {
  790.             j = ikPalette[i];
  791.             if (j <= 0)
  792.               kMainA[-j] = l;
  793.             else
  794.               kRainbowA[j] = l;
  795.           } else
  796.             EnsureN(l, FValidColor(l), "palette color");
  797.         }
  798.       }
  799.       wi.fRedraw = fTrue;
  800.     }
  801.     if (wParam == IDOK || wParam == IDCANCEL) {
  802.       EndDialog(hdlg, fTrue);
  803.       return fTrue;
  804.     }
  805.     break;
  806.   }
  807.   return fFalse;
  808. }
  809.  
  810.  
  811. /* Processing function for the chart info entry dialog, as brought up by  */
  812. /* both the Info Set Chart Info and Info Set Chart #2 Info menu commands. */
  813.  
  814. bool API DlgInfo(hdlg, message, wParam, lParam)
  815. HWND hdlg;
  816. _int message;
  817. WORD wParam;
  818. LONG lParam;
  819. {
  820.   CI ci;
  821.   char sz[cchSzDef];
  822.  
  823.   switch (message) {
  824.   case WM_INITDIALOG:
  825.     if (wi.nDlgChart < 2)
  826.       ci = ciMain;
  827.     else {
  828.       sprintf(sz, "Enter Chart #%d Info", wi.nDlgChart);
  829.       SetWindowText(hdlg, sz);
  830.       if (wi.nDlgChart == 2)
  831.         ci = ciTwin;
  832.       else if (wi.nDlgChart == 3)
  833.         ci = ciThre;
  834.       else
  835.         ci = ciFour;
  836.     }
  837. LInit:
  838.     SetEditMDYT(hdlg, dcInMon, dcInDay, dcInYea, dcInTim,
  839.       ci.mon, ci.day, ci.yea, ci.tim);
  840.     SetEditSZOA(hdlg, dcInDst, dcInZon, dcInLon, dcInLat,
  841.       ci.dst, ci.zon, ci.lon, ci.lat);
  842.     SetEditSz(hdlg, deInNam, ciMain.nam);
  843.     SetEditSz(hdlg, deInLoc, ciMain.loc);
  844.     SetFocus(GetDlgItem(hdlg, dcInMon));
  845.     return fFalse;
  846.  
  847.   case WM_COMMAND:
  848.     if (wParam == dbInNow || wParam == dbInSet) {
  849.       if (wParam == dbInNow) {
  850.         GetTimeNow(&ci.mon, &ci.day, &ci.yea, &ci.tim, us.zonDef-us.dstDef);
  851.         ci.dst = us.dstDef; ci.zon = us.zonDef;
  852.         ci.lon = us.lonDef; ci.lat = us.latDef;
  853.       } else
  854.         ci = ciSave;
  855.       goto LInit;
  856.     }
  857.  
  858.     if (wParam == IDOK) {
  859.       GetEdit(dcInMon, sz); ci.mon = NParseSz(sz, pmMon);
  860.       GetEdit(dcInDay, sz); ci.day = NParseSz(sz, pmDay);
  861.       GetEdit(dcInYea, sz); ci.yea = NParseSz(sz, pmYea);
  862.       GetEdit(dcInTim, sz); ci.tim = RParseSz(sz, pmTim);
  863.       GetEdit(dcInDst, sz); ci.dst = RParseSz(sz, pmDst);
  864.       GetEdit(dcInZon, sz); ci.zon = RParseSz(sz, pmZon);
  865.       GetEdit(dcInLon, sz); ci.lon = RParseSz(sz, pmLon);
  866.       GetEdit(dcInLat, sz); ci.lat = RParseSz(sz, pmLat);
  867.       EnsureN(ci.mon, FValidMon(ci.mon), "month");
  868.       EnsureN(ci.yea, FValidYea(ci.yea), "year");
  869.       EnsureN(ci.day, FValidDay(ci.day, ci.mon, ci.yea), "day");
  870.       EnsureR(ci.tim, FValidTim(ci.tim), "time");
  871.       EnsureR(ci.dst, FValidZon(ci.dst), "daylight");
  872.       EnsureR(ci.zon, FValidZon(ci.zon), "zone");
  873.       EnsureR(ci.lon, FValidLon(ci.lon), "longitude");
  874.       EnsureR(ci.lat, FValidLat(ci.lat), "latitude");
  875.       GetEdit(deInNam, sz);
  876.       ci.nam = SzPersist(sz);
  877.       GetEdit(deInLoc, sz);
  878.       ci.loc = SzPersist(sz);
  879.       switch (wi.nDlgChart) {
  880.       case 1:  ciMain = ciCore = ci; break;
  881.       case 2:  ciTwin = ci; break;
  882.       case 3:  ciThre = ci; break;
  883.       default: ciFour = ci; break;
  884.       }
  885.       wi.fCast = fTrue;
  886.     }
  887.     if (wParam == IDOK || wParam == IDCANCEL) {
  888.       EndDialog(hdlg, fTrue);
  889.       return fTrue;
  890.     }
  891.     break;
  892.   }
  893.   return fFalse;
  894. }
  895.  
  896.  
  897. /* Processing function for the default chart info dialog, as brought up */
  898. /* with the Info Default Chart Info menu command.                       */
  899.  
  900. bool API DlgDefault(hdlg, message, wParam, lParam)
  901. HWND hdlg;
  902. _int message;
  903. WORD wParam;
  904. LONG lParam;
  905. {
  906.   CI ci;
  907.   char sz[cchSzDef];
  908.  
  909.   switch (message) {
  910.   case WM_INITDIALOG:
  911.     SetEditSZOA(hdlg, dcDeDst, dcDeZon, dcDeLon, dcDeLat,
  912.       us.dstDef, us.zonDef, us.lonDef, us.latDef);
  913.     SetFocus(GetDlgItem(hdlg, dcDeDst));
  914.     return fFalse;
  915.  
  916.   case WM_COMMAND:
  917.     if (wParam == IDOK) {
  918.       GetEdit(dcDeDst, sz); ci.dst = RParseSz(sz, pmDst);
  919.       GetEdit(dcDeZon, sz); ci.zon = RParseSz(sz, pmZon);
  920.       GetEdit(dcDeLon, sz); ci.lon = RParseSz(sz, pmLon);
  921.       GetEdit(dcDeLat, sz); ci.lat = RParseSz(sz, pmLat);
  922.       EnsureR(ci.dst, FValidZon(ci.dst), "daylight");
  923.       EnsureR(ci.zon, FValidZon(ci.zon), "zone");
  924.       EnsureR(ci.lon, FValidLon(ci.lon), "longitude");
  925.       EnsureR(ci.lat, FValidLat(ci.lat), "latitude");
  926.       us.dstDef = ci.dst; us.zonDef = ci.zon;
  927.       us.lonDef = ci.lon; us.latDef = ci.lat;
  928.       wi.fCast = fTrue;
  929.     }
  930.     if (wParam == IDOK || wParam == IDCANCEL) {
  931.       EndDialog(hdlg, fTrue);
  932.       return fTrue;
  933.     }
  934.     break;
  935.   }
  936.   return fFalse;
  937. }
  938.  
  939.  
  940. /* Processing function for the charts #3 and #4 info entry dialog, as */
  941. /* brought up by the Info Charts #3 and #4 menu commands.             */
  942.  
  943. bool API DlgInfoAll(hdlg, message, wParam, lParam)
  944. HWND hdlg;
  945. _int message;
  946. WORD wParam;
  947. LONG lParam;
  948. {
  949.   DLGPROC dlgproc;
  950.   int i;
  951.  
  952.   switch (message) {
  953.   case WM_INITDIALOG:
  954.     i = us.nRel;
  955.     if (i > rcDual)
  956.       i = 0;
  957.     else if (i < rcQuadWheel)
  958.       i = rcDual;
  959.     SetRadio(dr01-i, dr01, dr04);
  960.     return fTrue;
  961.  
  962.   case WM_COMMAND:
  963.     if (FBetween(wParam, dbIa_o1, dbIa_o4)) {
  964.       wi.nDlgChart = wParam - dbIa_o1 + 1;
  965.       DlgOpenChart();
  966.     } else if (FBetween(wParam, dbIa_i1, dbIa_i4)) {
  967.       wi.nDlgChart = wParam - dbIa_i1 + 1;
  968.       WiDoDialog(DlgInfo, dlgInfo);
  969.     }
  970.     if (wParam == IDOK) {
  971.       i = GetCheck(dr01) ? 1 : (GetCheck(dr02) ? 2 : (GetCheck(dr03) ? 3 : 4));
  972.       SetRel(-(i-1));
  973.     }
  974.     if (wParam == IDOK || wParam == IDCANCEL) {
  975.       EndDialog(hdlg, fTrue);
  976.       return fTrue;
  977.     }
  978.     break;
  979.   }
  980.   return fFalse;
  981. }
  982.  
  983.  
  984. /* Processing function for the aspect settings dialog, as brought up with */
  985. /* the Setting Aspect Settings menu command.                              */
  986.  
  987. bool API DlgAspect(hdlg, message, wParam, lParam)
  988. HWND hdlg;
  989. _int message;
  990. WORD wParam;
  991. LONG lParam;
  992. {
  993.   int i, j;
  994.   real r;
  995.  
  996.   switch (message) {
  997.   case WM_INITDIALOG:
  998.     for (i = 1; i <= cAspect; i++) {
  999.       SetCheck(dxa01 - 1 + i, i > us.nAsp);
  1000.       SetEditR(hdlg, deo01 - 1 + i, rAspOrb[i], 2);
  1001.       SetEditR(hdlg, dea01 - 1 + i, rAspAngle[i], 6);
  1002.       SetEditR(hdlg, dei01 - 1 + i, rAspInf[i], 2);
  1003.     }
  1004.     return fTrue;
  1005.  
  1006.   case WM_COMMAND:
  1007.     switch (wParam) {
  1008.     case dbAs_RA0:
  1009.       for (i = 1; i <= cAspect; i++)
  1010.         SetCheck(dxa01 - 1 + i, fTrue);
  1011.       break;
  1012.     case dbAs_RA1:
  1013.       for (i = 1; i <= cAspect; i++)
  1014.         SetCheck(dxa01 - 1 + i, fFalse);
  1015.       break;
  1016.     case dbAs_RA:
  1017.       for (i = 1; i <= 5; i++)
  1018.         SetCheck(dxa01 - 1 + i, !GetCheck(dxa01 - 1 + i));
  1019.       break;
  1020.     }
  1021.  
  1022.     if (wParam == IDOK) {
  1023.       for (j = 0; j <= 1; j++) {
  1024.         for (i = 1; i <= cAspect; i++) {
  1025.           r = GetEditR(hdlg, deo01 - 1 + i);
  1026.           if (j)
  1027.             rAspOrb[i] = r;
  1028.           else
  1029.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "orb");
  1030.         }
  1031.         for (i = 1; i <= cAspect; i++) {
  1032.           r = GetEditR(hdlg, dea01 - 1 + i);
  1033.           if (j)
  1034.             rAspAngle[i] = r;
  1035.           else
  1036.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "angle");
  1037.         }
  1038.         for (i = 1; i <= cAspect; i++) {
  1039.           r = GetEditR(hdlg, dei01 - 1 + i);
  1040.           if (j)
  1041.             rAspInf[i] = r;
  1042.         }
  1043.       }
  1044.       for (us.nAsp = cAspect; us.nAsp > 0 && GetCheck(dxa01 - 1 + us.nAsp);
  1045.         us.nAsp--)
  1046.         ;
  1047.       for (i = 1; i <= us.nAsp; i++) {
  1048.         if (GetCheck(dxa01 - 1 + i))
  1049.           rAspOrb[i] = -rDegHalf;
  1050.       }
  1051.       wi.fRedraw = fTrue;
  1052.     }
  1053.     if (wParam == IDOK || wParam == IDCANCEL) {
  1054.       EndDialog(hdlg, fTrue);
  1055.       return fTrue;
  1056.     }
  1057.     break;
  1058.   }
  1059.   return fFalse;
  1060. }
  1061.  
  1062.  
  1063. /* Processing function for the object settings dialog, as brought up with */
  1064. /* the Setting Object Settings menu command.                              */
  1065.  
  1066. bool API DlgObject(hdlg, message, wParam, lParam)
  1067. HWND hdlg;
  1068. _int message;
  1069. WORD wParam;
  1070. LONG lParam;
  1071. {
  1072.   int i, j;
  1073.   real r;
  1074.  
  1075.   switch (message) {
  1076.   case WM_INITDIALOG:
  1077.     for (i = 1; i <= oCore; i++) {
  1078.       SetEditR(hdlg, deo01 - 1 + i, rObjOrb[i], 2);
  1079.       SetEditR(hdlg, dea01 - 1 + i, rObjAdd[i], 1);
  1080.       SetEditR(hdlg, dei01 - 1 + i, rObjInf[i], 2);
  1081.     }
  1082.     return fTrue;
  1083.  
  1084.   case WM_COMMAND:
  1085.     if (wParam == IDOK) {
  1086.       for (j = 0; j <= 1; j++) {
  1087.         for (i = 1; i <= oCore; i++) {
  1088.           r = GetEditR(hdlg, deo01 - 1 + i);
  1089.           if (j)
  1090.             rObjOrb[i] = r;
  1091.           else
  1092.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "max orb");
  1093.         }
  1094.         for (i = 1; i <= oCore; i++) {
  1095.           r = GetEditR(hdlg, dea01 - 1 + i);
  1096.           if (j)
  1097.             rObjAdd[i] = r;
  1098.           else
  1099.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "orb addition");
  1100.         }
  1101.         for (i = 1; i <= oCore; i++) {
  1102.           r = GetEditR(hdlg, dei01 - 1 + i);
  1103.           if (j)
  1104.             rObjInf[i] = r;
  1105.         }
  1106.       }
  1107.       wi.fRedraw = fTrue;
  1108.     }
  1109.     if (wParam == IDOK || wParam == IDCANCEL) {
  1110.       EndDialog(hdlg, fTrue);
  1111.       return fTrue;
  1112.     }
  1113.     break;
  1114.   }
  1115.   return fFalse;
  1116. }
  1117.  
  1118.  
  1119. /* Processing function for the cuap and uranian object settings dialog, as */
  1120. /* brought up with the Setting More Object Settings menu command.          */
  1121.  
  1122. bool API DlgObject2(hdlg, message, wParam, lParam)
  1123. HWND hdlg;
  1124. _int message;
  1125. WORD wParam;
  1126. LONG lParam;
  1127. {
  1128.   int i, j;
  1129.   real r;
  1130.  
  1131.   switch (message) {
  1132.   case WM_INITDIALOG:
  1133.     for (i = oAsc; i <= uranHi; i++) {
  1134.       SetEditR(hdlg, deo01 - oAsc + i, rObjOrb[i], 2);
  1135.       SetEditR(hdlg, dea01 - oAsc + i, rObjAdd[i], 1);
  1136.       SetEditR(hdlg, dei01 - oAsc + i, rObjInf[i], 2);
  1137.     }
  1138.     return fTrue;
  1139.  
  1140.   case WM_COMMAND:
  1141.     if (wParam == IDOK) {
  1142.       for (j = 0; j <= 1; j++) {
  1143.         for (i = oAsc; i <= uranHi; i++) {
  1144.           r = GetEditR(hdlg, deo01 - oAsc + i);
  1145.           if (j)
  1146.             rObjOrb[i] = r;
  1147.           else
  1148.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "max orb");
  1149.         }
  1150.         for (i = oAsc; i <= uranHi; i++) {
  1151.           r = GetEditR(hdlg, dea01 - oAsc + i);
  1152.           if (j)
  1153.             rObjAdd[i] = r;
  1154.           else
  1155.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "orb addition");
  1156.         }
  1157.         for (i = oAsc; i <= uranHi; i++) {
  1158.           r = GetEditR(hdlg, dei01 - oAsc + i);
  1159.           if (j)
  1160.             rObjInf[i] = r;
  1161.         }
  1162.       }
  1163.       wi.fRedraw = fTrue;
  1164.     }
  1165.     if (wParam == IDOK || wParam == IDCANCEL) {
  1166.       EndDialog(hdlg, fTrue);
  1167.       return fTrue;
  1168.     }
  1169.     break;
  1170.   }
  1171.   return fFalse;
  1172. }
  1173.  
  1174.  
  1175. /* Processing function for the object restrictions dialog, as invoked with */
  1176. /* both the Setting Restrictions and Transit Restrictions menu commands.   */
  1177.  
  1178. bool API DlgRestrict(hdlg, message, wParam, lParam)
  1179. HWND hdlg;
  1180. _int message;
  1181. WORD wParam;
  1182. LONG lParam;
  1183. {
  1184.   byte *lpb, *lpb2;
  1185.   int i;
  1186.  
  1187.   switch (message) {
  1188.   case WM_INITDIALOG:
  1189.     if (wi.wCmd == cmdRes)
  1190.       lpb = ignore;
  1191.     else {
  1192.       SetWindowText(hdlg, "Transit Object Restrictions");
  1193.       lpb = ignore2;
  1194.     }
  1195.     for (i = 1; i <= oNorm; i++)
  1196.       SetCheck(dx01 - 1 + i, lpb[i]);
  1197.     return fTrue;
  1198.  
  1199.   case WM_COMMAND:
  1200.     switch (wParam) {
  1201.     case dbRe_R0:
  1202.       for (i = 1; i <= oNorm; i++)
  1203.         SetCheck(dx01 - 1 + i, fTrue);
  1204.       break;
  1205.     case dbRe_R1:
  1206.       for (i = 1; i <= oNorm; i++)
  1207.         SetCheck(dx01 - 1 + i, fFalse);
  1208.       break;
  1209.     case dbRe_R:
  1210.       for (i = oMain+1; i <= oCore; i++)
  1211.         SetCheck(dx01 - 1 + i, !GetCheck(dx01 - 1 + i));
  1212.       break;
  1213.     case dbRe_RC:
  1214.       for (i = cuspLo; i <= cuspHi; i++)
  1215.         SetCheck(dx01 - 1 + i, !GetCheck(dx01 - 1 + i));
  1216.       break;
  1217.     case dbRe_Ru:
  1218.       for (i = uranLo; i <= uranHi; i++)
  1219.         SetCheck(dx01 - 1 + i, !GetCheck(dx01 - 1 + i));
  1220.       break;
  1221.     case dbRT:
  1222.       lpb2 = wi.wCmd == cmdRes ? ignore2 : ignore;
  1223.       for (i = 1; i <= oNorm; i++)
  1224.         SetCheck(dx01 - 1 + i, lpb2[i]);
  1225.       break;
  1226.     }
  1227.  
  1228.     if (wParam == IDOK) {
  1229.       lpb = wi.wCmd == cmdRes ? ignore : ignore2;
  1230.       for (i = 1; i <= oNorm; i++)
  1231.         lpb[i] = GetCheck(dx01 - 1 + i);
  1232.       if (!us.fCusp) {
  1233.         for (i = cuspLo; i <= cuspHi; i++)
  1234.           if (!ignore[i] || !ignore2[i]) {
  1235.             us.fCusp = fTrue;
  1236.             WiCheckMenu(cmdResCusp, fTrue);
  1237.             break;
  1238.           }
  1239.       } else {
  1240.         for (i = cuspLo; i <= cuspHi; i++)
  1241.           if (!ignore[i] || !ignore2[i])
  1242.             break;
  1243.         if (i > cuspHi) {
  1244.           us.fCusp = fFalse;
  1245.           WiCheckMenu(cmdResCusp, fFalse);
  1246.         }
  1247.       }
  1248.       if (!us.fUranian) {
  1249.         for (i = uranLo; i <= uranHi; i++)
  1250.           if (!ignore[i] || !ignore2[i]) {
  1251.             us.fUranian = fTrue;
  1252.             WiCheckMenu(cmdResUranian, fTrue);
  1253.             break;
  1254.           }
  1255.       } else {
  1256.         for (i = uranLo; i <= uranHi; i++)
  1257.           if (!ignore[i] || !ignore2[i])
  1258.             break;
  1259.         if (i > uranHi) {
  1260.           us.fUranian = fFalse;
  1261.           WiCheckMenu(cmdResUranian, fFalse);
  1262.         }
  1263.       }
  1264.       wi.fCast = fTrue;
  1265.     }
  1266.     if (wParam == IDOK || wParam == IDCANCEL) {
  1267.       EndDialog(hdlg, fTrue);
  1268.       return fTrue;
  1269.     }
  1270.     break;
  1271.   }
  1272.   return fFalse;
  1273. }
  1274.  
  1275.  
  1276. /* Processing function for the star restrictions dialog, as brought up with */
  1277. /* the Setting Star Restrictions menu command.                              */
  1278.  
  1279. bool API DlgStar(hdlg, message, wParam, lParam)
  1280. HWND hdlg;
  1281. _int message;
  1282. WORD wParam;
  1283. LONG lParam;
  1284. {
  1285.   int i;
  1286.  
  1287.   switch (message) {
  1288.   case WM_INITDIALOG:
  1289.     for (i = 1; i <= cStar; i++)
  1290.       SetCheck(dx01 - 1 + i, ignore[oNorm + i]);
  1291.     return fTrue;
  1292.  
  1293.   case WM_COMMAND:
  1294.     switch (wParam) {
  1295.     case dbSt_RU0:
  1296.       for (i = 1; i <= cStar; i++)
  1297.         SetCheck(dx01 - 1 + i, fTrue);
  1298.       break;
  1299.     case dbSt_RU1:
  1300.       for (i = 1; i <= cStar; i++)
  1301.         SetCheck(dx01 - 1 + i, fFalse);
  1302.       break;
  1303.     }
  1304.  
  1305.     if (wParam == IDOK) {
  1306.       for (i = 1; i <= cStar; i++)
  1307.         ignore[oNorm + i] = GetCheck(dx01 - 1 + i);
  1308.       if (!us.nStar) {
  1309.         for (i = starLo; i <= starHi; i++)
  1310.           if (!ignore[i]) {
  1311.             us.nStar = fTrue;
  1312.             WiCheckMenu(cmdResStar, fTrue);
  1313.             break;
  1314.           }
  1315.       } else {
  1316.         for (i = starLo; i <= starHi; i++)
  1317.           if (!ignore[i])
  1318.             break;
  1319.         if (i > starHi) {
  1320.           us.nStar = fFalse;
  1321.           WiCheckMenu(cmdResStar, fFalse);
  1322.         }
  1323.       }
  1324.       wi.fCast = fTrue;
  1325.     }
  1326.     if (wParam == IDOK || wParam == IDCANCEL) {
  1327.       EndDialog(hdlg, fTrue);
  1328.       return fTrue;
  1329.     }
  1330.     break;
  1331.   }
  1332.   return fFalse;
  1333. }
  1334.  
  1335.  
  1336. /* Processing function for the standard settings dialog, as brought up with */
  1337. /* the Setting Calculation Settings menu command.                           */
  1338.  
  1339. bool API DlgSetting(hdlg, message, wParam, lParam)
  1340. HWND hdlg;
  1341. _int message;
  1342. WORD wParam;
  1343. LONG lParam;
  1344. {
  1345.   char sz[cchSzDef];
  1346.   real r1;
  1347.   int n2, n3, n4, n5, n6;
  1348.  
  1349.   switch (message) {
  1350.   case WM_INITDIALOG:
  1351.     SetEditR(hdlg, deSe_s, us.rZodiacOffset, 6);
  1352.     SetEditN(deSe_A, us.nAsp);
  1353.     SetEditN(deSe_x, us.nHarmonic);
  1354.     SetEdit(deSe_h, szObjName[us.objCenter]);
  1355.     SetRadio(us.objOnAsc == 0 ? dr01 : (us.objOnAsc > 0 ? dr02 : dr03),
  1356.       dr01, dr03);
  1357.     SetEdit(deSe_1, szObjName[us.objOnAsc == 0 ? oSun : abs(us.objOnAsc)]);
  1358.     SetEditN(deSe_I, us.nScreenWidth);
  1359.     SetCheck(dxSe_b, us.fPlacalc);
  1360.     SetRadio(us.nDegForm == 0 ? dr04 : (us.nDegForm == 1 ? dr05 : dr06),
  1361.       dr04, dr06);
  1362.     SetCheck(dxSe_sr, us.fEquator);
  1363.     return fTrue;
  1364.  
  1365.   case WM_COMMAND:
  1366.     if (wParam == IDOK) {
  1367.       r1 = GetEditR(hdlg, deSe_s);
  1368.       GetEdit(deSe_A, sz); n2 = NParseSz(sz, pmAspect);
  1369.       n3 = GetEditN(deSe_x);
  1370.       GetEdit(deSe_h, sz); n4 = NParseSz(sz, pmObject);
  1371.       GetEdit(deSe_1, sz); n5 = NParseSz(sz, pmObject);
  1372.       n6 = GetEditN(deSe_I);
  1373.       EnsureR(r1, FValidOffset(r1), "zodiac offset");
  1374.       EnsureN(n2, FValidAspect(n2), "aspect count");
  1375.       EnsureN(n3, FValidHarmonic(n3), "harmonic factor");
  1376.       EnsureN(n4, FValidCenter(n4), "central planet");
  1377.       EnsureN(n5, FItem(n5), "Solar chart planet");
  1378.       EnsureN(n6, FValidScreen(n6), "text columns");
  1379.       us.rZodiacOffset = r1;
  1380.       us.nAsp = n2;
  1381.       us.nHarmonic = n3;
  1382.       us.objCenter = n4;
  1383.       us.objOnAsc = GetCheck(dr01) ? 0 : (GetCheck(dr02) ? n5 : -n5);
  1384.       us.nScreenWidth = n6;
  1385.       us.fPlacalc = GetCheck(dxSe_b);
  1386.       us.nDegForm = GetCheck(dr04) ? 0 : (GetCheck(dr05) ? 1 : 2);
  1387.       us.fEquator = GetCheck(dxSe_sr);
  1388.       WiCheckMenu(cmdHeliocentric, us.objCenter != oEar);
  1389.       wi.fCast = fTrue;
  1390.     }
  1391.     if (wParam == IDOK || wParam == IDCANCEL) {
  1392.       EndDialog(hdlg, fTrue);
  1393.       return fTrue;
  1394.     }
  1395.     break;
  1396.   }
  1397.   return fFalse;
  1398. }
  1399.  
  1400.  
  1401. /* Processing function for the obscure settings dialog, as brought up with */
  1402. /* the Setting Obscure Settings menu command.                              */
  1403.  
  1404. bool API DlgObscure(hdlg, message, wParam, lParam)
  1405. HWND hdlg;
  1406. _int message;
  1407. WORD wParam;
  1408. LONG lParam;
  1409. {
  1410.   int i, n1;
  1411.  
  1412.   switch (message) {
  1413.   case WM_INITDIALOG:
  1414.     SetCheck(dxOb_Yn, us.fTrueNode);
  1415.     SetCheck(dxOb_Yd, us.fEuroDate);
  1416.     SetCheck(dxOb_Yt, us.fEuroTime);
  1417.     SetCheck(dxOb_YC, us.fSmartCusp);
  1418.     SetCheck(dxOb_Y8, us.fClip80);
  1419.     SetCheck(dxOb_Yo, us.fWriteOld);
  1420.     SetCheck(dxOb_Yc0, us.fHouseAngle);
  1421.     SetCheck(dxOb_YR0_s, us.fIgnoreSign);
  1422.     SetCheck(dxOb_YR0_d, us.fIgnoreDir);
  1423.     SetEditN(deOb_YXg, gs.nGridCell);
  1424.     SetCheck(dxOb_YXf, gs.fFont);
  1425.     SetEditR(hdlg, deOb_YXp0_x, gs.xInch, 2);
  1426.     SetEditR(hdlg, deOb_YXp0_y, gs.yInch, 2);
  1427.     SetRadio(gs.nOrient == 0 ? dr11 : (gs.nOrient > 0 ? dr09 : dr10),
  1428.       dr09, dr11);
  1429.     SetRadio(dr01 + (gs.nGlyphs/1000 == 2), dr01, dr02);
  1430.     SetRadio(dr03 + ((gs.nGlyphs/100)%10 == 2), dr03, dr04);
  1431.     SetRadio(dr05 + ((gs.nGlyphs/10)%10 == 2), dr05, dr06);
  1432.     SetRadio(dr07 + (gs.nGlyphs%10 == 2), dr07, dr08);
  1433.     for (i = 0; i < 4; i++)
  1434.       SetCheck(dx01 + i, ignorez[i]);
  1435.     return fTrue;
  1436.  
  1437.   case WM_COMMAND:
  1438.     if (wParam == IDOK) {
  1439.       n1 = GetEditN(deOb_YXg);
  1440.       EnsureN(n1, FValidGrid(n1), "grid cell");
  1441.       us.fTrueNode = GetCheck(dxOb_Yn);
  1442.       us.fEuroDate = GetCheck(dxOb_Yd);
  1443.       us.fEuroTime = GetCheck(dxOb_Yt);
  1444.       us.fSmartCusp = GetCheck(dxOb_YC);
  1445.       us.fClip80 = GetCheck(dxOb_Y8);
  1446.       us.fWriteOld = GetCheck(dxOb_Yo);
  1447.       us.fHouseAngle = GetCheck(dxOb_Yc0);
  1448.       us.fIgnoreSign = GetCheck(dxOb_YR0_s);
  1449.       us.fIgnoreDir = GetCheck(dxOb_YR0_d);
  1450.       gs.nGridCell = n1;
  1451.       gs.fFont = GetCheck(dxOb_YXf);
  1452.       gs.xInch = GetEditR(hdlg, deOb_YXp0_x);
  1453.       gs.yInch = GetEditR(hdlg, deOb_YXp0_y);
  1454.       gs.nOrient = GetCheck(dr11) ? 0 : (GetCheck(dr09) ? 1 : -1);
  1455.       gs.nGlyphs = (GetCheck(dr01) ? 1 : 2) * 1000 + (GetCheck(dr03) ? 1 : 2) *
  1456.         100 + (GetCheck(dr05) ? 1 : 2) * 10 + (GetCheck(dr07) ? 1 : 2);
  1457.       for (i = 0; i < 4; i++)
  1458.         ignorez[i] = GetCheck(dx01 + i);
  1459.       wi.fCast = fTrue;
  1460.     }
  1461.     if (wParam == IDOK || wParam == IDCANCEL) {
  1462.       EndDialog(hdlg, fTrue);
  1463.       return fTrue;
  1464.     }
  1465.     break;
  1466.   }
  1467.   return fFalse;
  1468. }
  1469.  
  1470.  
  1471. /* Processing function for the transit chart dialog, as brought up with the */
  1472. /* Chart Transits menu command.                                             */
  1473.  
  1474. bool API DlgTransit(hdlg, message, wParam, lParam)
  1475. HWND hdlg;
  1476. _int message;
  1477. WORD wParam;
  1478. LONG lParam;
  1479. {
  1480.   char sz[cchSzDef];
  1481.   int mon, day, yea, n1, n2;
  1482.   real tim;
  1483.  
  1484.   switch (message) {
  1485.   case WM_INITDIALOG:
  1486.     if (us.fInDay)           n1 = 1;
  1487.     else if (us.fInDayInf)   n1 = 2;
  1488.     else if (us.fTransit)    n1 = 3;
  1489.     else if (us.fTransitInf) n1 = 4;
  1490.     else                     n1 = 0;
  1491.     SetRadio(dr01 + n1, dr01, dr05);
  1492.     SetCheck(dxTr_p, is.fProgress);
  1493.     SetCheck(dxTr_r, is.fReturn);
  1494.     SetEditMDYT(hdlg, dcTrMon, dcTrDay, dcTrYea, dcTrTim,
  1495.       MonT, DayT, YeaT, TimT);
  1496.     if (n1 == 1) {
  1497.       n2 = is.fProgress || us.fInDayMonth;
  1498.       if (n2 == 1 && MonT == 0)
  1499.         n2 += 1 + (us.nEphemYears > 1);
  1500.     } else if (n1 == 3)
  1501.       n2 = 1 + (MonT <= 0) + (MonT < 0);
  1502.     else
  1503.       n2 = 0;
  1504.     SetRadio(dr06 + n2, dr06, dr09);
  1505.     SetEditN(deTr_tY, us.nEphemYears);
  1506.     SetEditN(deTr_d, us.nDivision);
  1507.     SetFocus(GetDlgItem(hdlg, dcTrMon));
  1508.     return fFalse;
  1509.  
  1510.   case WM_COMMAND:
  1511.     if (wParam == dbTr_tn) {
  1512.       GetTimeNow(&mon, &day, &yea, &tim, us.zonDef-us.dstDef);
  1513.       SetEditMDYT(hdlg, dcTrMon, dcTrDay, dcTrYea, dcTrTim,
  1514.         mon, day, yea, tim);
  1515.     }
  1516.  
  1517.     if (wParam == IDOK) {
  1518.       GetEdit(dcTrMon, sz); mon = NParseSz(sz, pmMon);
  1519.       GetEdit(dcTrDay, sz); day = NParseSz(sz, pmDay);
  1520.       GetEdit(dcTrYea, sz); yea = NParseSz(sz, pmYea);
  1521.       GetEdit(dcTrTim, sz); tim = RParseSz(sz, pmTim);
  1522.       n1 = GetEditN(deTr_tY);
  1523.       n2 = GetEditN(deTr_d);
  1524.       EnsureN(mon, FValidMon(mon), "month");
  1525.       EnsureN(yea, FValidYea(yea), "year");
  1526.       EnsureN(day, FValidDay(day, mon, yea), "day");
  1527.       EnsureR(tim, FValidTim(tim), "time");
  1528.       EnsureN(n2, FValidDivision(n2), "searching divisions");
  1529.       SetCI(ciTran, mon, day, yea, tim,
  1530.         us.dstDef, us.zonDef, us.lonDef, us.latDef);
  1531.       us.nEphemYears = n1;
  1532.       us.nDivision = n2;
  1533.       is.fProgress = GetCheck(dxTr_p);
  1534.       is.fReturn = GetCheck(dxTr_r);
  1535.       n1 = GetCheck(dr01) ? 0 : (GetCheck(dr02) ? 1 : (GetCheck(dr03) ? 2 :
  1536.         (GetCheck(dr04) ? 3 : 4)));
  1537.       switch (n1) {
  1538.       case 1: wi.nMode = gTraTraHit; break;
  1539.       case 2: wi.nMode = gTraTraInf; break;
  1540.       case 3: wi.nMode = gTraNatHit; break;
  1541.       case 4: wi.nMode = gTraNatInf; break;
  1542.       default: wi.nMode = gWheel;
  1543.       }
  1544.       n2 = GetCheck(dr06) ? 0 : (GetCheck(dr07) ? 1 :
  1545.         (GetCheck(dr08) ? 2 : 3));
  1546.       if (n1 == 1) {
  1547.         us.fInDayMonth = (is.fProgress || n2 >= 1);
  1548.         if (n2 >= 2) {
  1549.           MonT = 0;
  1550.           if (n2 == 2)
  1551.             us.nEphemYears = 1;
  1552.         }
  1553.       } else if (n1 == 3) {
  1554.         if (n2 == 2)
  1555.           MonT = 0;
  1556.         else if (n2 == 3) {
  1557.           MonT = -1; DayT = us.nEphemYears;
  1558.         }
  1559.       } else if (n1 == 2) {
  1560.         us.fProgress = is.fProgress;
  1561.         wi.fCast = fTrue;
  1562.       }
  1563.       us.fGraphics = fFalse;
  1564.       wi.fRedraw = fTrue;
  1565.     }
  1566.     if (wParam == IDOK || wParam == IDCANCEL) {
  1567.       EndDialog(hdlg, fTrue);
  1568.       return fTrue;
  1569.     }
  1570.     break;
  1571.   }
  1572.   return fFalse;
  1573. }
  1574.  
  1575.  
  1576. /* Processing function for the progression settings dialog, as brought up */
  1577. /* with the Chart Progressions menu command.                              */
  1578.  
  1579. bool API DlgProgress(hdlg, message, wParam, lParam)
  1580. HWND hdlg;
  1581. _int message;
  1582. WORD wParam;
  1583. LONG lParam;
  1584. {
  1585.   char sz[cchSzDef];
  1586.   int mon, day, yea;
  1587.   real tim, r1;
  1588.  
  1589.   switch (message) {
  1590.   case WM_INITDIALOG:
  1591.     SetCheck(dxPr_p, us.fProgress);
  1592.     SetEditMDYT(hdlg, dcPrMon, dcPrDay, dcPrYea, dcPrTim,
  1593.       MonT, DayT, YeaT, TimT);
  1594.     SetRadio(dr01 + us.fSolarArc, dr01, dr02);
  1595.     SetEditR(hdlg, dcPr_pd, us.rProgDay, 5);
  1596.     SetCombo(dcPr_pd, "365.25");
  1597.     SetCombo(dcPr_pd, "27.321661");
  1598.     SetCombo(dcPr_pd, "29.530588");
  1599.     SetFocus(GetDlgItem(hdlg, dcPrMon));
  1600.     return fFalse;
  1601.  
  1602.   case WM_COMMAND:
  1603.     if (wParam == dbPr_pn) {
  1604.       GetTimeNow(&mon, &day, &yea, &tim, us.zonDef-us.dstDef);
  1605.       SetEditMDYT(hdlg, dcPrMon, dcPrDay, dcPrYea, dcPrTim,
  1606.         mon, day, yea, tim);
  1607.     }
  1608.  
  1609.     if (wParam == IDOK) {
  1610.       GetEdit(dcPrMon, sz); mon = NParseSz(sz, pmMon);
  1611.       GetEdit(dcPrDay, sz); day = NParseSz(sz, pmDay);
  1612.       GetEdit(dcPrYea, sz); yea = NParseSz(sz, pmYea);
  1613.       GetEdit(dcPrTim, sz); tim = RParseSz(sz, pmTim);
  1614.       r1 = GetEditR(hdlg, dcPr_pd);
  1615.       EnsureN(mon, FValidMon(mon), "month");
  1616.       EnsureN(yea, FValidYea(yea), "year");
  1617.       EnsureN(day, FValidDay(day, mon, yea), "day");
  1618.       EnsureR(tim, FValidTim(tim), "time");
  1619.       EnsureR(r1, r1 != 0.0, "degree per day");
  1620.       SetCI(ciTran, mon, day, yea, tim,
  1621.         us.dstDef, us.zonDef, us.lonDef, us.latDef);
  1622.       us.rProgDay = r1;
  1623.       us.fProgress = GetCheck(dxPr_p);
  1624.       us.fSolarArc = GetCheck(dr02);
  1625.       is.JDp = MdytszToJulian(MonT, DayT, YeaT, TimT, us.dstDef, us.zonDef);
  1626.       wi.fCast = fTrue;
  1627.     }
  1628.     if (wParam == IDOK || wParam == IDCANCEL) {
  1629.       EndDialog(hdlg, fTrue);
  1630.       return fTrue;
  1631.     }
  1632.     break;
  1633.   }
  1634.   return fFalse;
  1635. }
  1636.  
  1637.  
  1638. /* Processing function for the chart subsettings dialog, as brought up with */
  1639. /* the Chart Chart Settings menu command.                                   */
  1640.  
  1641. bool API DlgChart(hdlg, message, wParam, lParam)
  1642. HWND hdlg;
  1643. _int message;
  1644. WORD wParam;
  1645. LONG lParam;
  1646. {
  1647.   int n1, n2, n3;
  1648.   bool f;
  1649.  
  1650.   switch (message) {
  1651.   case WM_INITDIALOG:
  1652.     SetCheck(dxCh_v0, us.fVelocity);
  1653.     SetEditN(deCh_w, us.nWheelRows);
  1654.     SetCheck(dxCh_w0, us.fWheelReverse);
  1655.     SetCheck(dxCh_g0, us.fGridConfig);
  1656.     SetCheck(dxCh_a0, us.fAspSummary);
  1657.     SetCheck(dxCh_m0, us.fMidSummary);
  1658.     SetCheck(dxCh_ma, us.fMidAspect);
  1659.     SetCheck(dxCh_Z0, us.fPrimeVert);
  1660.     SetCheck(dxCh_l, us.fSectorApprox);
  1661.     SetCheck(dxCh_j0, us.fInfluenceSign);
  1662.     SetEditN(deCh_L, us.nAstroGraphStep);
  1663.     SetCheck(dxCh_L0, us.fLatitudeCross);
  1664.     SetCheck(dxCh_Ky, us.fCalendarYear);
  1665.     SetEditN(deCh_P, us.nArabicParts);
  1666.     SetCheck(dxCh_P0, us.fArabicFlip);
  1667.     switch (us.nStar) {
  1668.     case 'z': n1 = dr02; break;
  1669.     case 'l': n1 = dr03; break;
  1670.     case 'n': n1 = dr04; break;
  1671.     case 'b': n1 = dr05; break;
  1672.     default:  n1 = dr01;
  1673.     }
  1674.     SetRadio(n1, dr01, dr05);
  1675.     switch (us.nArabic) {
  1676.     case 'z': n2 = dr07; break;
  1677.     case 'n': n2 = dr08; break;
  1678.     case 'f': n2 = dr09; break;
  1679.     default:  n2 = dr06;
  1680.     }
  1681.     SetRadio(n2, dr06, dr09);
  1682.     return fTrue;
  1683.  
  1684.   case WM_COMMAND:
  1685.     if (wParam == IDOK) {
  1686.       n1 = GetEditN(deCh_w);
  1687.       n2 = GetEditN(deCh_L);
  1688.       n3 = GetEditN(deCh_P);
  1689.       EnsureN(n1, FValidWheel(n1), "wheel row");
  1690.       EnsureN(n2, FValidAstrograph(n2), "astro-graph step");
  1691.       EnsureN(n3, FValidPart(n3), "Arabic part");
  1692.       f = GetCheck(dxCh_v0);
  1693.       if (us.fVelocity != f) {
  1694.         us.fVelocity = f;
  1695.         WiCheckMenu(cmdGraphicsSidebar, !f);
  1696.       }
  1697.       us.nWheelRows = n1;
  1698.       us.fWheelReverse = GetCheck(dxCh_w0);
  1699.       us.fGridConfig = GetCheck(dxCh_g0);
  1700.       us.fAspSummary = GetCheck(dxCh_a0);
  1701.       us.fMidSummary = GetCheck(dxCh_m0);
  1702.       us.fMidAspect = GetCheck(dxCh_ma);
  1703.       us.fPrimeVert = GetCheck(dxCh_Z0);
  1704.       us.fSectorApprox = GetCheck(dxCh_l);
  1705.       us.fInfluenceSign = GetCheck(dxCh_j0);
  1706.       us.nAstroGraphStep = n2;
  1707.       us.fLatitudeCross = GetCheck(dxCh_L0);
  1708.       us.fCalendarYear = GetCheck(dxCh_Ky);
  1709.       us.nArabicParts = n3;
  1710.       us.fArabicFlip = GetCheck(dxCh_P0);
  1711.       if (us.nStar)
  1712.         us.nStar = GetCheck(dr02) ? 'z' : (GetCheck(dr03) ? 'l' :
  1713.           (GetCheck(dr04) ? 'n' : (GetCheck(dr05) ? 'b' : fTrue)));
  1714.       if (us.nArabic)
  1715.         us.nArabic = GetCheck(dr07) ? 'z' : (GetCheck(dr08) ? 'n' :
  1716.           (GetCheck(dr09) ? 'f' : fTrue));
  1717.       wi.fCast = fTrue;
  1718.     }
  1719.     if (wParam == IDOK || wParam == IDCANCEL) {
  1720.       EndDialog(hdlg, fTrue);
  1721.       return fTrue;
  1722.     }
  1723.     break;
  1724.   }
  1725.   return fFalse;
  1726. }
  1727.  
  1728.  
  1729. /* Processing function for the graphic settings dialog, as brought up with */
  1730. /* the Graphics Graphics Settings menu command.                            */
  1731.  
  1732. bool API DlgGraphics(hdlg, message, wParam, lParam)
  1733. HWND hdlg;
  1734. _int message;
  1735. WORD wParam;
  1736. LONG lParam;
  1737. {
  1738.   char sz[cchSzDef];
  1739.   int n1, n2, n3, n5, n6;
  1740.   real r4;
  1741.  
  1742.   switch (message) {
  1743.   case WM_INITDIALOG:
  1744.     SetEditN(deGr_Xw_x, gs.xWin);
  1745.     SetEditN(deGr_Xw_y, gs.yWin);
  1746.     SetEditN(deGr_XW, gs.nRot);
  1747.     SetEditR(hdlg, deGr_XG, gs.rTilt, 2);
  1748.     SetCheck(dxGr_XW0, gs.fMollewide);
  1749.     SetEditN(deGr_WN, wi.nTimerDelay);
  1750.     SetRadio(gs.objLeft > 0 ? dr02 :
  1751.       (gs.objLeft < 0 ? dr03 : dr01), dr01, dr03);
  1752.     SetEdit(deGr_X1, szObjName[gs.objLeft == 0 ? oSun : abs(gs.objLeft)]);
  1753.     SetCheck(dxGr_Wn, wi.fNoUpdate);
  1754.     return fTrue;
  1755.  
  1756.   case WM_COMMAND:
  1757.     if (wParam == IDOK) {
  1758.       n1 = GetEditN(deGr_Xw_x);
  1759.       n2 = GetEditN(deGr_Xw_y);
  1760.       n3 = GetEditN(deGr_XW);
  1761.       r4 = GetEditR(hdlg, deGr_XG);
  1762.       n5 = GetEditN(deGr_WN);
  1763.       GetEdit(deGr_X1, sz); n6 = NParseSz(sz, pmObject);
  1764.       EnsureN(n1, FValidGraphx(n1), "horizontal size");
  1765.       EnsureN(n2, FValidGraphy(n2), "vertical size");
  1766.       EnsureN(n3, FValidRotation(n3), "horizontal rotation");
  1767.       EnsureR(r4, FValidTilt(r4), "vertical tilt");
  1768.       EnsureN(n5, FValidTimer(n5), "animation delay");
  1769.       EnsureN(n5, FItem(n6), "rotation planet");
  1770.       if (gs.xWin != n1 || gs.yWin != n2) {
  1771.         gs.xWin = n1; gs.yWin = n2;
  1772.         if (wi.fWindowChart)
  1773.           ResizeWindowToChart();
  1774.       }
  1775.       gs.nRot = n3; gs.rTilt = r4;
  1776.       if (wi.nTimerDelay != (UINT)n5) {
  1777.         wi.nTimerDelay = n5;
  1778.         if (wi.nTimer != 0)
  1779.           KillTimer(wi.hwnd, 1);
  1780.         wi.nTimer = SetTimer(wi.hwnd, 1, wi.nTimerDelay, NULL);
  1781.       }
  1782.       gs.objLeft = GetCheck(dr01) ? 0 : (GetCheck(dr02) ? n6 : -n6);
  1783.       gs.fMollewide = GetCheck(dxGr_XW0);
  1784.       wi.fNoUpdate = GetCheck(dxGr_Wn);
  1785.       us.fGraphics = wi.fRedraw = fTrue;
  1786.     }
  1787.     if (wParam == IDOK || wParam == IDCANCEL) {
  1788.       EndDialog(hdlg, fTrue);
  1789.       return fTrue;
  1790.     }
  1791.     break;
  1792.   }
  1793.   return fFalse;
  1794. }
  1795.  
  1796.  
  1797. /* Processing function for the about dialog, showing copyrights and  */
  1798. /* credits, as brought up with the Help About Astrolog menu command. */
  1799.  
  1800. bool API DlgAbout(hdlg, message, wParam, lParam)
  1801. HWND hdlg;
  1802. _int message;
  1803. WORD wParam;
  1804. LONG lParam;
  1805. {
  1806.   switch (message) {
  1807.   case WM_INITDIALOG:
  1808.     return fTrue;
  1809.  
  1810.   case WM_COMMAND:
  1811.     if (wParam == IDOK || wParam == IDCANCEL) {
  1812.       EndDialog(hdlg, fTrue);
  1813.       return fTrue;
  1814.     }
  1815.     break;
  1816.   }
  1817.   return fFalse;
  1818. }
  1819. #endif /* WIN */
  1820.  
  1821. /* wdialog.c */
  1822.